import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect:'/home/index'
  },
  {
    path:'/home',
    name:'home',
    component:HomeView,
    children:[
      {
        path:'index',
        name:'/home/index',
        component:()=>import('../views/Index.vue')
      },
      {
        path:'branch-list',
        name:'/home/branch-list',
        component:()=>import('../views/branch/BranchList.vue'),
        meta:{
          nav:['分店管理','分店列表'],
          divider:'分店列表'
        }
      },
      {
        path:'branch-add',
        name:'/home/branch-add',
        component:()=>import('../views/branch/BranchAdd.vue'),
        meta:{
          nav:['分店管理','新增分店'],
          divider:'新增分店'
        }
      },
      {
        path:'dish-list',
        name:'/home/dish-list',
        component:()=>import('../views/dish/DishList.vue'),
        meta:{
          nav:['菜品管理','菜品列表'],
          divider:'菜品列表'
        }
      },
      {
        path:'dish-add',
        name:'/home/dish-add',
        component:()=>import('../views/dish/DishAdd.vue'),
        meta:{
          nav:['菜品管理','新增菜品'],
          divider:'新增菜品'
        }
      },
      {
        path:'user-list',
        name:'/home/user-list',
        component:()=>import('../views/user/UserList.vue'),
        meta:{
          nav:['用户管理','用户列表'],
          divider:'用户列表'
        }
      },
      {
        path:'user-add',
        name:'/home/user-add',
        component:()=>import('../views/user/UserAdd.vue'),
        meta:{
          nav:['用户管理','新增用户'],
          divider:'新增用户'
        }
      }
      
    ]
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
